<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.2/vue.global.js"></script>
</head>
<body>
    <div id="app"></div>
</body>
<script>
    const app = Vue.createApp({
        data(){
            return{

            }
        },
        methods:{

        },
        // 异步组件组件.调用三秒后执行
        template:`
        <div><async-component /></div>
        `
    })
    app.component('async-component',
    // 声明这是一个异步组件
        Vue.defineAsyncComponent(()=>{
            return new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve({
                        template:`<div>这是一个异步组件</div>`
                    })
                },3000)
            })
        })
    )
    app.mount("#app")
</script>
</html>